package com.zx.cloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zx.cloud.ApiVersion;
import com.zx.cloud.controller.client.RoleClient;
import com.zx.cloud.domain.Role;
import com.zx.cloud.model.response.ObjectDataResponse;
import com.zx.cloud.model.response.Response;
import com.zx.cloud.util.Page;

import io.swagger.annotations.ApiOperation;

/**
 * @author Alex
 */
@RestController
@RequestMapping(value = ApiVersion.MANAGER_V1_PREFIX + "/role", produces = { MediaType.APPLICATION_JSON_UTF8_VALUE }, consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE })
public class RoleController {

	@Autowired
	private RoleClient roleClient;

	//@MagicPermission 接口权限
	@ApiOperation(value = "查询角色信息", notes = "查询角色信息")
	@RequestMapping(value = "/queryRole", method = RequestMethod.POST)
	@ResponseBody
	public ObjectDataResponse<Page<Role>> queryRole(@RequestBody Role role) {
		return roleClient.queryRole(role);
	}



	@ApiOperation(value = "修改角色内容", notes = "修改角色内容")
	@RequestMapping(value = "/updateRole", method = RequestMethod.POST)
	@ResponseBody
	public Response updateRole(@RequestBody Role role) {
		ObjectDataResponse<Integer> success= roleClient.updateRole(role);
		return  success;
	}

	@ApiOperation(value = "添加角色内容", notes = "添加角色内容")
	@RequestMapping(value = "/addRole", method = RequestMethod.POST)
	@ResponseBody
	public  ObjectDataResponse<Integer> addRole(@RequestBody Role role) {
		
		ObjectDataResponse<Integer> success = roleClient.addRole(role);
		return success;
	}


	@ApiOperation(value = "删除角色内容", notes = "删除角色内容")
	@RequestMapping(value = "/deleteRole", method = RequestMethod.POST)
	@ResponseBody
	public Response deleteRole(@RequestBody Role role) {
		ObjectDataResponse<Object> data= roleClient.removeRole(role);
		return  data;
	}
//	
//	@IgnoreAuth
//	@MagicPermission
//	@ApiOperation(value = "删除角色内容", notes = "删除角色内容")
//	@RequestMapping(value = "/deleteRole", method = RequestMethod.POST)
//	@ResponseBody
//	public Response deleteRole(@RequestBody Role role) {
//		ObjectDataResponse<Integer> success = roleClient.removeRole(role);
//		return success;
//	}
	

}
